function getStyle(el, property){
    return getComputedStyle(el)[property] ? getComputedStyle(el)[property] : el.currentStyle[property]
}

function animation(el, property, target){
    var current;
    var speed;
    clearInterval(el.ani);
    el.ani = setInterval(function(){
        if(property === 'opacity'){
            if(target > 100 || target < 0){
                console.log('输入的透明度不正确');
                clearInterval(el.ani);
            }else{
                current = parseInt(getStyle(el, property) * 100)
            }
        }else{
            current = parseInt(getStyle(el, property))
        }
        speed = (target - current) / 30;
        if(speed == 0){
            clearInterval(el.ani);
        }
        speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
        if(property === 'opacity'){
            el.style[property] = (current + speed) / 100;
        }else{
            el.style[property] = current + speed + 'px';
        }
        // console.log('?')
    },20)

}